#ifndef CHARTWIDGET_H
#define CHARTWIDGET_H

#include <QWidget>
#include "posix_qextserialport.h"
#include <QMessageBox>
#include <QFile>
#include <QTimer>
#include "qcustomplot.h"

//延时，TIME_OUT是串口读写的延时
#define TIME_OUT 10

//读取定时器计时间隔,200ms，读取定时器是我们读取串口缓存的延时
#define TIMER_INTERVAL 500

namespace Ui {
class ChartWidget;
}

class ChartWidget : public QWidget
{
    Q_OBJECT
    
public:
    explicit ChartWidget(QWidget *parent = 0);
    ~ChartWidget();
    
private slots:
    void on_StartChartbtn_clicked();
    void on_StopChartbtn_clicked();
    void readMyComA();       //读取串口A
    void realtimeDataSlot();

private:
    Ui::ChartWidget *ui;
    void startInit();
    void setComboBoxEnabled(bool status);
    void setupRealtimeDataDemo(QCustomPlot *customPlot);
    int timerdly;
    Posix_QextSerialPort *myComA;   //定义串口A

    QTimer *readTimerA;  //定时器A
    QTimer *dataTimer;
    QMutex mutex;
     int tempdata;
      int humdata;


};

#endif // CHARTWIDGET_H
